import log from './logger'
import config from "./config";
import {axios} from "../node-test";

function send(path: "trainNode" | "train" | "trainAll", data: any) {
    return new Promise((resolve, reject) => {
        // log.info("send begin")
        axios.post(config.url + path, data).then((res) => {
            // log.info("send ok")
            if (res.data.code === '0000') {
                resolve("ok");
            } else {
                log.error("send err data:", path, data)
                log.error("send err:", res.data.code, res.data.data)
                reject("post err");
            }
        }).catch((e) => {
            log.error("send err:", e.message)
            reject("err");
        })
    })

}

export default {send};